<template>
	<view class="container">
		<view class="top_box" style="
		background: url(https://test.danawebsite.top/storage/images/public/back.png) no-repeat;
		background-size: 750rpx 564rpx;" :style="{'paddingTop':topIconDistance+'px'}">
			<view class="top_bar" :style="{'height':statusBarHeight+'px'}">
				<view class="back" @click="$backTo()">
					<u-icon name="arrow-left"></u-icon>
				</view>
				<view>
					售后详情
				</view>
				<view style="width: 60rpx;"> </view>
			</view>
			<view class="status_box">
				<view>
					<view class="big">
						<image src="@/static/images/dengdai.png" mode=""></image>
						<text v-if="orderInfo.status == 1">申请中</text>
						<text v-else-if="orderInfo.status == 2">已处理</text>
						<text v-else-if="orderInfo.status == 3">已取消</text>
					</view>
					<view class="small">请等待平台确认申请</view>
				</view>
			</view>
		</view>
		<view class="my_order">
			<view class="icon">
				<u-icon name="map" color="#EA3D37" size="40"></u-icon>
			</view>
			<view class="address">
				<view class="user">收货人：{{orderInfo.address_name}} {{orderInfo.address_phone}}</view>
				<view class="city">{{orderInfo.address}}</view>
			</view>
		</view>
		<view class="goods_box">
			<view class="title">
				<view class="order_num">订单商品</view>
				<view class="status">{{orderInfo.total_num}}件商品</view>
			</view>
			<view class="content_con">
				<view class="content_box" v-for="(item,index) in orderInfo.detaillist" :key="index2">
					<view class="img_box">
						<image :src="item.product_thumb" mode="aspectFill"></image>
					</view>
					<view class="infos">
						<view class="name">
							{{item.product_name}}
						</view>
						<view class="sku">
							{{item.spec_name}}
						</view>
						<view class="dan_price">
							￥{{item.spec_price}}
							<text>x{{item.num}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="btns">
				<view></view>
				<view class="count_box">
					已优惠：￥{{orderInfo.coupon_price}}　合计：<text>￥{{orderInfo.total_fee}}</text>
				</view>
			</view> -->
		</view>
		<view class="order_info">
			<view class="order_title">订单信息</view>
			<view class="num">退货原因：{{orderInfo.reason_type}}</view>
			<!-- <view class="num">金额：{{orderInfo}}</view> -->
			<view class="num">申请时间：{{orderInfo.create_time}}</view>
			<view class="num">订单编号：{{orderInfo.order_num}}</view>
			<view class="num">备注：{{orderInfo.reason}}</view>
			<view class="img_box">
				<view class="title" style="margin-bottom: 20rpx;">凭证：</view>
				<view class="images">
					<view class="img" v-for="(item,index) in orderInfo.images_path" :key="index"
						@click="lookImages(index)">
						<image :src="item" mode=""></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderInfo: null,
				topIconDistance: 0,
				statusBarHeight: 0,
				orderId: 0,
			}
		},
		onShow() {

		},
		onLoad(opdata) {
			uni.getSystemInfo({
				success: (res) => {
					// 获取手机顶部状态栏的高度
					const statusBarHeight = res.statusBarHeight || 0;

					// 获取导航栏的高度（手机状态栏高度 + 胶囊高度 + 胶囊的上下间距）
					const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
					const navBarHeight = menuButtonInfo.height + (menuButtonInfo.top - statusBarHeight) *
						2;
					// 计算顶部图标距离
					this.topIconDistance = navBarHeight;
					this.statusBarHeight = statusBarHeight;

					// 打印顶部图标距离
				},
				fail: (err) => {
					console.error('获取系统信息失败:', err);
				},
			});
			this.orderId = opdata.id
			this.getApplyInfo()
		},
		methods: {
			lookImages(index) {
				uni.previewImage({
					urls: this.images,
					current: index
				})
			},
			getApplyInfo(id) {
				this.$allApi.getApplyInfo({
					order_id: this.orderInfo.images_path
				}).then(res => {
					this.orderInfo = res.data
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.order_info {
		width: 710rpx;
		border-radius: 20rpx;
		background: #FFFFFF;
		margin: 0 auto;
		padding: 20rpx;

		.num {
			line-height: 1.8;
			font-size: 24rpx;
			color: #333333;
		}

		.order_title {
			padding-bottom: 20rpx;
			border-bottom: #ECECEC;
		}
	}

	.foot {
		width: 710rpx;
		height: 80rpx;
		border-radius: 10rpx;
		background: #EA3D37;
		left: 20rpx;
		position: fixed;
		bottom: calc(20rpx + constant(safe-area-inset-bottom));
		bottom: calc(20rpx + env(safe-area-inset-bottom));
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
	}

	.foot2 {
		width: 710rpx;
		height: 80rpx;
		background: #FFFFFF;
		border: 2rpx solid #EA3D37;
		border-radius: 10rpx;
		left: 20rpx;
		position: fixed;
		bottom: calc(20rpx + constant(safe-area-inset-bottom));
		bottom: calc(20rpx + env(safe-area-inset-bottom));
		display: flex;
		align-items: center;
		justify-content: center;
		color: #EA3D37;
	}

	.goods_box {
		width: 710rpx;
		margin: 30rpx auto;
		padding: 20rpx 30rpx;
		background: #fff;
		border-radius: 20rpx;

		.btns {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-top: 20rpx;

			text {
				font-weight: bold;
				color: #EA3D37;
			}
		}

		.title {
			padding-bottom: 20rpx;
			position: relative;
			border-bottom: 1px solid #eee;
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #333;
			justify-content: space-between;

			.status {
				color: #999999
			}
		}

		.content_con {
			padding-top: 30rpx;
			padding-bottom: 20rpx;
			border-bottom: 1px solid #eee;

			.head {
				padding: 20rpx 0;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.left {
					display: flex;
					align-items: center;

					image {
						width: 50rpx;
						height: 50rpx;
						border-radius: 10rpx;
						margin-right: 20rpx;
					}
				}
			}

			.content_box {
				display: flex;
				justify-content: space-between;
				margin-bottom: 20rpx;

				.img_box {
					width: 240rpx;
					height: 240rpx;

					image {
						width: 240rpx;
						height: 240rpx;
						border-radius: 20rpx;
					}
				}

				.infos {
					flex: 1;
					padding-left: 20rpx;

					.dan_price {
						font-size: 32rpx;
						color: #EA3D37;
						display: flex;
						justify-content: space-between;
						align-items: center;

						text {
							font-size: 24rpx;
							color: #999;
						}
					}

					.name {
						font-size: 32rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 3;
						overflow: hidden;
					}

					.sku {
						font-size: 28rpx;
						color: #999;
						margin: 20rpx 0;
					}

				}
			}

		}
	}

	.status_box {
		height: 290rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;
		color: #fff;

		.big {
			font-size: 36rpx;
			display: flex;
			align-items: center;
			justify-content: center;

			image {
				width: 34rpx;
				height: 34rpx;
				margin-right: 20rpx;
			}
		}

		.small {
			font-size: 24rpx;
			margin-top: 16rpx;
		}
	}

	.top_bar {
		width: 100vw;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 10rpx;
		color: #fff;

		.back {
			width: 60rpx;
			height: 60rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 40rpx;
		}
	}

	.my_order {
		width: 710rpx;
		margin: 0 auto;
		margin-top: -110rpx;
		background: #fff;
		border-radius: 20rpx;
		height: 160rpx;
		padding: 20rpx;
		padding-top: 30rpx;
		display: flex;
		justify-content: space-between;

		.address {
			flex: 1;
			padding-left: 20rpx;

			.user {
				font-weight: 500;
			}

			.city {
				color: #999999;
				margin-top: 8rpx;
			}
		}
	}

	.top_box {
		height: 564rpx;
	}

	.container {
		min-height: 100vh;
		background: #F8F8F8;
		padding-bottom: calc(30rpx + env(safe-area-inset-bottom)
		}
</style>